



        var animate = null;
        var preventScrl = false;
        var swpInd = 0;
        var scrlDownStatus = false;
        var scaleDelay = null;

        var prjctSwiper = new Swiper('.prjctSwiper',{
            centeredSlides:true,
            loop:true,
            slidesPerView:'auto',
            speed:800,
            on: {
                touchStart: function(event){
                    var evt = event || window.event;
                    console.log(evt.target);
                },
            },
        })

        function transformTwice(ele,val,cssName){
            var eleProcess;
            if(ele[0].process == undefined){
                for(var p = 0;p < ele.parents().length;p++){
                    if(ele.parents()[p].process != undefined){
                        eleProcess = ele.parents()[p].process;
                        break;
                    }
                }
            }else{
                eleProcess = ele[0].process;
            }
            ele[0].style.transform = cssName + '(' + (val + (-val * 2 * eleProcess)) + 'px)';
        }

        function scrollProcess(){
            for(var e = 0;e < $('.scrollItem').length;e++){
                var windowTop = $('.scrollItem')[e].getBoundingClientRect().top;
                var itemHeight = $('.scrollItem')[e].offsetHeight;
                var widnowHeight = window.innerHeight;
                if($('.scrollItem')[e].scrollStop == "overself" && $('.scrollItem')[e].scrollStart == 'former'){
                    if(windowTop > widnowHeight){
                        $('.scrollItem')[e].process = 0;
                    }else if(windowTop <= widnowHeight && windowTop > -itemHeight){
                        $('.scrollItem')[e].process = (widnowHeight - windowTop) / (itemHeight + widnowHeight);
                    }else if(windowTop <= -itemHeight){
                        $('.scrollItem')[e].process = 1;
                    }
                }else if($('.scrollItem')[e].scrollStop.indexOf('%') >= 0 && $('.scrollItem')[e].scrollStart.indexOf('%') >= 0){
                    var scrollStop = parseFloat($('.scrollItem')[e].scrollStop);
                    var scrollStart = parseFloat($('.scrollItem')[e].scrollStart);
                    if(windowTop > scrollStart * widnowHeight / 100){
                        $('.scrollItem')[e].process = 0;
                    }else if(windowTop <= scrollStart * widnowHeight / 100 && windowTop >= scrollStop * widnowHeight / 100){
                        $('.scrollItem')[e].process = (scrollStart * widnowHeight / 100 - windowTop) / ((scrollStart - scrollStop) * widnowHeight / 100);
                    }else{
                        $('.scrollItem')[e].process = 1;
                    }
                }
            }
            exclusiveActions();
        }

        function exclusiveActions(){
            transformTwice($('main .content .rhtPic'),-134,'translateY');
            $('main .content .btmPic')[0].style.transform = 'translateY(' + (-10 - $('main .content .btmPic')[0].process * 90) + 'px)';
            $('main .content .info .no')[0].style.transform = 'translateY(' + (-124 + $('main .content .info .no')[0].process * 184) + 'px)';
            $('main .floatPics .p1')[0].style.transform = 'translateX(' + (-20 + $('main .floatPics .p1')[0].process * 125) + 'px)';
            $('main .floatPics .p2')[0].style.transform = 'translateY(' + (-16 + $('main .floatPics .p2')[0].process * 74) + 'px)';
            $('main .floatPics .p3')[0].style.transform = 'translateY(' + (6 - $('main .floatPics .p3')[0].process * 246) + 'px)';
        }

        $(document).ready(function(){
            setTimeout(function(){
                $('main .banner').addClass('frozen');
            },10)

            $('main .banner .scrl').click(function(){
                console.log('zz');
                scrlDown();
            })

            var animations = [];
            for(var l = 0;l < $('.ready').length;l++){
                $('.ready')[l].ind = l;
                animations.push($('.ready')[l]);
            }
            for(var s = 0;s < $('.scrollItem').length;s++){
                $('.scrollItem')[s].scrollStart = $('.scrollItem:eq(' + s + ')').attr('scroll-start');
                $('.scrollItem')[s].scrollStop = $('.scrollItem:eq(' + s + ')').attr('scroll-stop');
            }

            scrollProcess();
            $(window).scroll(function(){
                scrollProcess();
            })

            animate = setInterval(function(){
        
                for(var r = 0;r < animations.length;r++){
                    var className = animations[r].className;
                    var ele_h = animations[r].offsetHeight;
                    var ele_top = animations[r].getBoundingClientRect().top;
                    var window_h = window.innerHeight;
                    if(className.indexOf('overHalf') >= 0){
                        ele_top += ele_h / 2;
                    }
                    //console.log(animations);
                    if(
                        (className.indexOf('overself') < 0 && ele_top < window_h)
                            ||
                            (className.indexOf('overself') >= 0 && ele_top <= window_h - ele_h)
                        ){
                        $('.ready').eq(r).addClass('frozen');     
                    }else{
                        $('.ready').eq(r).removeClass('frozen'); 
                    }
                }
            },10);

            $('.fltImg').click(function(){
                swpInd = 0;
                $('main .palace .swp .white').css('width',$('.palace .swp img')[swpInd].offsetWidth);
                $('main .palace .swp .white').css('height',$('.palace .swp img')[swpInd].offsetHeight);
                $('main .palace .swp .white').css('transition','.8s ease');
                $('main .palace .control p').removeClass('hidden');
                $('main .palace .control .prev').addClass('hidden');
                $('.palace .swp *').removeClass('active');
                $('.palace .swp img').eq(swpInd).addClass('active');
                $('.palace').addClass('active');
                
            })

            $('.palace .close,.palace .bg').click(function(){
                $('.palace').removeClass('active');
                $('main .palace .swp .white')[0].style.cssText = '';
            })
            
            $('.palace .control p').click(function(){
                if($(this)[0].className.indexOf('prev') >= 0){
                    swpInd--;
                    if(!swpInd){
                        $('main .palace .control .prev').addClass('hidden');
                    }else{
                        $('main .palace .control .next').removeClass('hidden');
                    }
                }else{
                    swpInd++;
                    if(swpInd == $('main .palace .swp img').length - 1){
                        $('main .palace .control .next').addClass('hidden');
                    }else{
                        $('main .palace .control .prev').removeClass('hidden');
                        
                    }
                }
                $('main .palace .swp .white').addClass('active');
                $('main .palace .swp img').removeClass('active');
                $('main .palace .control').addClass('hidden');
                $('main .palace .swp .white').css('width',$('.palace .swp img')[swpInd].offsetWidth);
                $('main .palace .swp .white').css('height',$('.palace .swp img')[swpInd].offsetHeight);
                setTimeout(function(){
                    $('main .palace .swp img').eq(swpInd).addClass('active');
                    $('main .palace .control').removeClass('hidden');
                },810)
            })
            

            $('main .foot .toTop').click(function(){
                scrollNew = 0;
                toTop = true;
            })

            $('.projects .contn .btn').click(function(){
                if($(this)[0].className.indexOf('prev') >= 0){
                    prjctSwiper.slidePrev(); 
                }else{
                    prjctSwiper.slideNext();
                }
            })

            $('.projects .swiper .swiper-slide').click(function(){
                if(scaleDelay) return false;
                $('.banner .inner .pic img').attr('src',$(this).find('img').attr('src'));
                $('.banner .inner').css('top',$(this)[0].getBoundingClientRect().top + 'px');
                var scaleDelayScds = $(this)[0].className.indexOf('active') >= 0?10:810;
                scaleDelay = setTimeout(function(){
                    $('.banner').removeClass('disappear');
                    $('.banner .inner').css('top','0px');
                },scaleDelayScds)
                setTimeout(function(){
                    window.location.href = 'case.html';
                },1000 + scaleDelayScds);
                if($(this)[0].className.indexOf('prev') >= 0){
                    prjctSwiper.slidePrev();
                }else if($(this)[0].className.indexOf('next') >= 0){
                    prjctSwiper.slideNext();
                }
                console.log($(this)[0].getBoundingClientRect().top,$(this)[0].getBoundingClientRect().left);
                
                
            })
        }) 